package com.unitedvision.core.domain;

import java.util.Date;

public class Transaction {
	private int id;
	private Operator operator;
	private Inventory inventory;
	private CompanyCustomer companyCustomer;
	private Date transactionDate;
	private int typeDescriptor;
	private int numberOfGoods;
	private long cost;
	
	public Transaction() {
		super();
	}

	public Transaction(int id, Operator operator, Inventory inventory, CompanyCustomer companyCustomer, int typeDescriptor, int numberOfGoods, long cost, Date transactionDate) {
		super();
		this.id = id;
		this.operator = operator;
		this.inventory = inventory;
		this.companyCustomer = companyCustomer;
		this.typeDescriptor = typeDescriptor;
		this.numberOfGoods = numberOfGoods;
		this.cost = cost;
		this.transactionDate = transactionDate;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Operator getOperator() {
		return operator;
	}

	public void setOperator(Operator operator) {
		this.operator = operator;
	}

	public Inventory getInventory() {
		return inventory;
	}

	public void setInventory(Inventory inventory) {
		this.inventory = inventory;
	}

	public CompanyCustomer getCompanyCustomer() {
		return companyCustomer;
	}

	public void setCompanyCustomer(CompanyCustomer companyCustomer) {
		this.companyCustomer = companyCustomer;
	}

	public Date getTransactionDate() {
		return transactionDate;
	}

	public void setTransactionDate(Date transactionDate) {
		this.transactionDate = transactionDate;
	}

	public int getTypeDescriptor() {
		return typeDescriptor;
	}

	public void setTypeDescriptor(int typeDescriptor) {
		this.typeDescriptor = typeDescriptor;
	}

	public int getNumberOfGoods() {
		return numberOfGoods;
	}

	public void setNumberOfGoods(int numberOfGoods) {
		this.numberOfGoods = numberOfGoods;
	}

	public long getCost() {
		return cost;
	}

	public void setCost(long cost) {
		this.cost = cost;
	}

	public Company getCompany() {
		return companyCustomer.getCompany();
	}

	@Override
	public String toString() {
		return "Transaction [id=" + id + ", operator=" + operator
				+ ", inventory=" + inventory + ", companyCustomer="
				+ companyCustomer + ", transactionDate=" + transactionDate
				+ ", typeDescriptor=" + typeDescriptor + ", numberOfGoods="
				+ numberOfGoods + ", cost=" + cost + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((companyCustomer == null) ? 0 : companyCustomer.hashCode());
		result = prime * result + (int) (cost ^ (cost >>> 32));
		result = prime * result + id;
		result = prime * result
				+ ((inventory == null) ? 0 : inventory.hashCode());
		result = prime * result + numberOfGoods;
		result = prime * result
				+ ((operator == null) ? 0 : operator.hashCode());
		result = prime * result
				+ ((transactionDate == null) ? 0 : transactionDate.hashCode());
		result = prime * result + typeDescriptor;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Transaction other = (Transaction) obj;
		if (companyCustomer == null) {
			if (other.companyCustomer != null)
				return false;
		} else if (!companyCustomer.equals(other.companyCustomer))
			return false;
		if (cost != other.cost)
			return false;
		if (id != other.id)
			return false;
		if (inventory == null) {
			if (other.inventory != null)
				return false;
		} else if (!inventory.equals(other.inventory))
			return false;
		if (numberOfGoods != other.numberOfGoods)
			return false;
		if (operator == null) {
			if (other.operator != null)
				return false;
		} else if (!operator.equals(other.operator))
			return false;
		if (transactionDate == null) {
			if (other.transactionDate != null)
				return false;
		} else if (!transactionDate.equals(other.transactionDate))
			return false;
		if (typeDescriptor != other.typeDescriptor)
			return false;
		return true;
	}
}
